﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;

namespace appLibrary
{
    public class DenifitionRoles
    {

        public static void getRolesUser(string strNameSP, Control objControl,int idRole,int idJerarquia,string strUser ) {

            ViewQueries viewQueries = new ViewQueries();

            DataSet dts = viewQueries.getSPQueries(strNameSP, null,idRole,idJerarquia);
            //Recorremos todos los permisos que tenga activado el usuario
            if (!(dts != null && dts.Tables != null && dts.Tables[0].Rows.Count > 0))
            {
                Log.eLog(strUser, "El usuario no tiene roles");
                return;
            }

            for (int i = 0; i < dts.Tables[0].Rows.Count; i++)
            {
                Util.EnabledControl(objControl, dts.Tables[0].Rows[i]["name_button"].ToString(), strUser);
            }
        } 

    }
}
